

/**************************************************************************
* *
* * FILE NAME : Common.cpp
* *
* * DESCRIPTION : Common cpp file
* *
* * DATE : 2024-2-16
* *
* * AUTHOR : TaskRunner
* *
* * MODIFY :
* *
**************************************************************************/


#include "Common.h"
#include <time.h>


//******************************************************************************
// definition of function
//******************************************************************************

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
U32 GetRandU32(U32 num) {
	static bool isSeek = false;

	if (isSeek == false) {
		srand((unsigned) time(NULL));
		isSeek = true;
	}
	return rand() % (num + 1);
}


//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
double GetRandomDouble(double num) {
	if (num <= 0) {
		return 0;
	}
	return ((double)GetRandU32(RAND_MAX) / RAND_MAX) * num;
}

